<?php 
require_once("nav.php");

 ?>
       <div class="col-sm-9 col-md-10">
<!DOCTYPE html>
<html>
<head>
  <title>美食列表</title>
</head>
<body>
<h1><center>美食列表</center></h1>
<center><a href="admin.php?c=food&m=foodform">添加美食</a></center></br>
<form method="POST" action="admin.php?c=food&m=foodsearch">
    <center><input type="text" name="foodname" class="form-control" placeholder="请输入美食名称">
    <button type="submit" class="btn btn-default">搜索</button></center></br>
</form>
 <table class="table table-hover">
 <tr>
  <th>美食ID</th>
  <th>美食名称</th>
  <th>美食类型</th>
  <th>海报</th>
  <th>内容简介</th>
  <th>添加日期</th>
  <th>点击率</th>
  <th>操作</th>
 </tr>

<?php
  define('UserPhotoPath','images/');
  static $count=0;
  foreach($data as $one){
    $count++;
    echo '<td>'.$one['fid'].'</td>';
    echo '<td>'.$one['foodname'].'</td>';
              if($one['tid']==1)
              {
                $one['tid']='热菜类';
              }
              if($one['tid']==2)
              {
                $one['tid']='凉菜类';
              }
               if($one['tid']==3)
              {
                $one['tid']='汤羹';
              }
               if($one['tid']==4)
              {
                $one['tid']='主食';
              }
               if($one['tid']==5)
              {
                $one['tid']='小吃';
              }
               if($one['tid']==6)
              {
                $one['tid']='饮品';
              }
               if($one['tid']==7)
              {
                $one['tid']='炮酱腌菜';
              }

    echo '<td>'.$one['tid'].'</td>';
    echo '<td align="center">
        <img src='.UserPhotoPath.$one['pic'].' width=100 height=120 alt="无海报"></td>';
    echo '<td>'.$one['intro'].'</td>';
    echo '<td>'.$one['uploaddate'].'</td>';
    echo '<td>'.$one['hittimes'].'</td>';
    echo '<td>
    <a href="admin.php?c=food&m=foodedit&id='.$one['fid'].' ">修改</a>| 
    <a href="admin.php?c=food&m=delfood&id='.$one['fid'].'" onClick="return confirm(\'确定要删除吗？\');">删除</a>
     </td>';
    echo '</tr>';  
  }
  echo '</table>';  
  echo "<table align='center'><tr><td>共有 {$count} 种美食</td></tr></table>";   
 ?>
 </body>
</html>
</div>

</div>

<?php 
require_once('footer.php');
 ?>